package com.zlx.guguanjia.config;

import com.zlx.guguanjia.Interceptor.LoginInterceptor;
import com.zlx.guguanjia.Interceptor.ResourceInteceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author 周罗校
 * @Description
 * @ClassName SpringMvcConfig
 * @date 2020.11.03 15:27:17
 * 该版权归周罗校所有，最终解释权以官方为准
 */

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    @Autowired
    private ResourceInteceptor resourceInteceptor;

    /**
     * 拦截注册
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        //登陆拦截
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns(new String[]{"/","/manager/","/**/*.html"})
                .excludePathPatterns(new String[]{"/notauth.html","/login.html","/notlogin.html"});
        //资源权限拦截
        registry.addInterceptor(resourceInteceptor)
                .addPathPatterns(new String[]{"/","/manager/","/**/*.html"})
                .excludePathPatterns(new String[]{"/notauth.html","/login.html","/notlogin.html"});
    }
}
